/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.oai.metadataRepository.repository.records.inMemory;

import cz.mzk.oai.metadataRepository.metadata.DateStamp;
import cz.mzk.oai.metadataRepository.metadata.MetadataFormat;
import cz.mzk.oai.metadataRepository.repository.Identifier;
import cz.mzk.oai.metadataRepository.repository.OaiSet;
import cz.mzk.oai.metadataRepository.repository.records.Record;
import cz.mzk.oai.metadataRepository.repository.records.presentAndDeleted.PresentRecord;
import java.io.IOException;
import java.util.Set;
import org.dom4j.Document;

/**
 *
 * @author Martin Řehánek (rehan at mzk.cz)
 */
public class RecordInMemory implements Record {

    private final Identifier id;
    private final MetadataFormat format;
    private final Document doc;

    public RecordInMemory(Record record) throws IOException {
        format = record.getMetadataFormat();
        id = record.getId();
        if (record.isDeleted()) {
            doc = null;
        } else {
            doc = ((PresentRecord) record).getMetadata();
        }
    }

    public Identifier getId() {
        return id;
    }

    public boolean isDeleted() {
        return doc == null;
    }

    public DateStamp getDateStamp() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Set<OaiSet> getOaiSets() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public MetadataFormat getMetadataFormat() {
        return format;
    }

    public Document getData(){
        return doc;
    }
}
